function initTableTrMouseAction() {
	$("table.list tr").mouseover(function() {
		$(this).find("td").addClass("mouseon")
	}).mouseout(function() {
		$(this).find("td").removeClass("mouseon")
	})
	/*
	 * $("table.list tr").click(function(){ alert(1) })
	 */
}

function btnLink(url) {
	if (console) {
		console.log(url);
	}
	window.location.href = url;
	return false;
}

function loadPageToDiv(obj) {
	$("#simpleMsg").html("");
	$("#" + $(obj).attr("_target")).load($(obj).attr("href"));
	return false;
}
/**
 * 
 * @param actionPath
 *            form提交表单地址
 * @param formId
 *            form表单id
 * @param callback
 *            回调方法 old:ajaxSubmitForm
 */

function ajaxSubmitForm(actionPath, formId, targetId, callback) {
	$("#" + formId).unbind('submit').bind("submit", function() {
		var action;
		if (typeof actionPath == 'undefined') {
			actionPath = this.action;
		} else {
			action = actionPath;
		}
		jQuery.ajax({
			data : $(this).serialize(),
			url : actionPath,
			type : this.method,
			error : function() {
				$("#" + targetId).html("error ");
			},
			success : function(results) {
				$("#" + targetId).html(results);
				if (eval(callback)) {
					eval(callback)();
				}
			}
		})
		return false;
	});
}
/**
 * 使用a来ajax提交表单
 * 
 * @param actionPath
 * @param formId
 * @param targetId
 * @param callback
 */
function ajaxChangeForm(actionPath, formId, targetId, callback) {
	jQuery.ajax({
		data : $("#" + formId).serialize(),
		url : actionPath,
		type : $("#" + formId).method,
		error : function() {
			$("#" + targetId).html("error ");
		},
		success : function(results) {
			$("#" + targetId).html(results);
			if (eval(callback)) {
				eval(callback)();
			}
		}
	});
}

function ajaxRefreshPage(actionPath, formId, targetId, callback) {
	ajaxChangeForm(actionPath, formId, targetId, callback);
}


function ajaxPageSizePage(actionPath, formId, targetId, callback) {
	$("#pageNum").val(0);
	ajaxChangeForm(actionPath, formId, targetId, callback);
}

function ajaxPrePageForm(actionPath, formId, targetId, callback) {
	$("#pageNum").val(eval($("#pageNum").val()) - 1);
	ajaxChangeForm(actionPath, formId, targetId, callback);
}
function ajaxNextPageForm(actionPath, formId, targetId, callback) {
	$("#pageNum").val(eval($("#pageNum").val()) + 1);
	ajaxChangeForm(actionPath, formId, targetId, callback);
}

/**
 * 
 * @param actionPath
 *            表单提交url
 * @param formId
 *            表单id
 * @param callback
 *            表单提交后方法回调
 * @param checkFormMehod
 *            表单校验方法
 */
function ajaxForm(actionPath, formId, callback, checkForm) {
	var notNeedChecked = true;
	if (eval(checkForm)) {
		notNeedChecked = eval(checkForm)(formId);
	}
	// 不需要验证了
	if (notNeedChecked) {
		$("#" + formId).unbind('submit').bind("submit", function() {
			var action;
			if (typeof actionPath == 'undefined') {
				actionPath = this.action;
			} else {
				action = actionPath;
			}
			jQuery.ajax({
				data : $(this).serialize(),
				url : actionPath,
				type : this.method,
				error : function() {
					alert("error");
				},
				success : function(results) {
					if (eval(callback)) {
						eval(callback)(results);
					}
				}
			})
			return false;
		});
	} else {
		return false;
	}
}

function covertJSON(data) {
	var json;
	try {
		json = eval("(" + data + ")");
	} catch (err) {
		win = window
				.open(path + "/debug.jsp", 'debug', 'width=300, height=400');

		win.document.write("<h1 style='color:red'>转json格式错误</h1>" + data);
	}
	return json;
}

function initCheckBox() {
	$("input.checkAll").click(
			function() {
				// $(this).attr("checked");
				$("input." + $(this).attr("targetClass")).attr("checked",
						$(this).attr("checked"));
			});
	$.each($("input.checkAll"), function(i, el) {
		$("input." + $(this).attr("targetClass")).click(function() {
			if (!$(this).attr("checked")) {
				$(el).attr("checked", $(this).attr("checked"));
			}
		});
		var targetCheckName = $(this).attr("targetClass");
		if ($("input." + targetCheckName).not("input:checked").length == 0) {
			// 全被选中
			if ($("input." + $(this).attr("targetClass")).length != 0) {
				$(this).attr("checked", "checked");
			} else {
				$(this).attr("disabled", true);
			}
		}
	});
}
